package com.luoxin.servicedriveruser.generator;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.util.Collections;

/**
 * 自动生成代码工具类
 */
public class MysqlGenerator {
    public static void main(String[] args) {
        FastAutoGenerator.create("jdbc:mysql://127.0.0.1:3306/service-driver-user?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&allowPublicKeyRetrieval=true", "root", "960312lx")
                .globalConfig(builder -> {
                    builder.author("lx") // 设置作者
                            .fileOverride() // 覆盖已生成文件
                            .outputDir("D:\\studyWorkspaceIDEA\\online-taxi\\service-driver-user\\src\\main\\java"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("com.luoxin.servicedriveruser")
                            .pathInfo(Collections.singletonMap(OutputFile.mapper,"D:\\studyWorkspaceIDEA\\online-taxi\\service-driver-user\\src\\main\\java\\com\\luoxin\\servicedriveruser\\mapper"));
                })
                .strategyConfig(builder -> {
                    builder.addExclude("driver_car_binding_relationship");
                })
                // 使用Freemarker引擎模板，默认的是Velocity引擎模板
                .templateEngine(new FreemarkerTemplateEngine())
                .execute();
    }
}
